<template>
  <div class="scrollbar">
    <el-scrollbar>
      <el-form
        label-position="top"
        :model="selectTable"
        ref="addForm"
        label-width="200px"
        :inline="false"
        autocomplete="off"
        >
        <el-row :gutter="20">
          <el-col style="text-align: center;">
           {{title}}
          </el-col>
        </el-row>
        <el-row :gutter="20" class="info">
          <el-col :span="6" class="els">
            分类：{{selectTable.articleClassify}}
          </el-col>
          <el-col :span="6">
            作者：{{selectTable.author}}
          </el-col>
        </el-row>
        <el-row :gutter="20" class="info">
          <div class="content-txt-box">
            <span>
            添加时间：{{selectTable.createTime | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}
            </span>
            <div>
            </div>
          </div>
        </el-row>
        <el-row :gutter="20" class="info">
          <el-col :span="12">
           标签：{{selectTable.keyword}}
          </el-col>
        </el-row>
         <el-row :gutter="20" class="info">
          <el-col :span="12">
           摘要：{{selectTable.summary}}
          </el-col>
        </el-row>
        <el-row :gutter="20" class="info">
          <el-col :span="20">
           <div v-html="selectTable.details"></div>
          </el-col>
        </el-row>
      </el-form>
    </el-scrollbar>
    <div v-loading="pload" class="footer">
      <el-button @click="$emit('close')">取 消</el-button>
      <!-- <el-button type="primary" @click="submitForm('addForm')">确 定</el-button> -->
    </div>
  </div>
</template>
<style lang="scss" scoped>
.scrollbar {
  height: 100%;
  overflow: hidden;
  padding-bottom: 50px;
  position: relative;
  .el-scrollbar {
    height: 100%;
  }
  .el-row {
    margin-bottom: 20px;
    border-bottom: 1px #e4e4e4 solid;
    padding-bottom: 20px;
  }
  .el-form {
    padding: 20px;
  }
  .info {
    font-size: 14px;
    color: #666;
    .el-col {
      white-space: nowrap;
      overflow: hidden;
      text-overflow:ellipsis;
    }
  }
  .title {
    text-align: center;
    font-size: 16px;
    border-bottom: 1px #e4e4e4 solid;
    padding-bottom: 15px;
    margin-bottom: 15px;
  }
  .footer {
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
  }
  .content-txt-box {
    display: flex;
    padding: 0 11px;
    span {

    }
    div {
      flex: 1;
    }
  }
}
</style>
<script>
import * as api from '@/utils/api'
export default {
  props: {
    data: Object
  },
  created() {
    this.selectTable = this.JSONs(this.data)
    if (this.selectTable.forbiddenStatus === 2) {
      this.selectTable.forbiddenStatus = null
    }
  },
  watch: {
    show(newVal) {
      this.$emit('close')
    }
  },
  computed: {
    title() {
      if (this.id) {
        return '修改'
      } else {
        return '添加'
      }
    }
  },
  data() {
    return {
      pload: false,
      rule: [
        { required: true, message: '必填项', trigger: 'change' }
      ],
      show: true,
      selectTable: {}
    }
  },
  methods: {
    async submitForm(formName) {
      await this.$refs[formName].validate()
      try {
        this.pload = true
        await api.ltsGdModify(this.selectTable)
        this.$notify({ title: '操作成功', type: 'success', duration: 5000 })
        this.$emit('close')
        this.$emit('getData')
      } catch (e) {
        this.pload = false
      }
    }
  }
}
</script>
